package ar.uba.fi.tp2Unit;

import ar.uba.fi.tp2Unit.assertions.Assertion;
import ar.uba.fi.tp2Unit.framework.TestCase;
import ar.uba.fi.tp2Unit.framework.TestFixture;
import ar.uba.fi.tp2Unit.framework.TestNameAlreadyExistsException;
import ar.uba.fi.tp2Unit.framework.TestSuite;

public class MyFirstTestSuiteWithSetUp extends TestSuite {
	
	public MyFirstTestSuiteWithSetUp(String name) throws TestNameAlreadyExistsException {
		super(name);
		this.addTest(new TestAddTwoInts("TestAddTwoInts"));
		this.addTest(new TestAddResultGreaterThanZero("TestAddResultGreaterThanZero"));
	}
	
	public void setUp(TestFixture fixture){
		fixture.add("valueOne", 2);
		fixture.add("valueTwo", 3);			
	}
	
	class TestAddTwoInts extends TestCase{

		public TestAddTwoInts(String name) {
			super(name);
		}

		@Override
		public void testMethod(TestFixture testFixture) throws Throwable {
			int valueOne = (Integer) testFixture.get("valueOne");
			int valueTwo = (Integer) testFixture.get("valueTwo");
			int result = valueOne + valueTwo;
			
			Assertion.assertEquals("La suma da 5!", 5, result);
		}
		
	}
	
	class TestAddResultGreaterThanZero extends TestCase{

		public TestAddResultGreaterThanZero(String name) {
			super(name);
		}

		@Override
		public void testMethod(TestFixture testFixture) throws Throwable {
			int valueOne = (Integer) testFixture.get("valueOne");
			int valueTwo = (Integer) testFixture.get("valueTwo");
			int result = valueOne + valueTwo;
			
			Assertion.assertTrue(result > 0);
		}
		
	}
}
